#include "LensCompensation.h"

LensCompensation::LensCompensation()
{

}

void LensCompensation::loadSettings(QSettings &settings)
{
    m_lensWD[0] = settings.value("LensWD/LENS0", 0.0).toDouble();
    m_lensWD[1] = settings.value("LensWD/LENS1", 0.0).toDouble();
    m_lensWD[2] = settings.value("LensWD/LENS2", 0.0).toDouble();
    m_lensWD[3] = settings.value("LensWD/LENS3", 0.0).toDouble();
    m_lensWD[4] = settings.value("LensWD/LENS4", 0.0).toDouble();
    m_lensWD[5] = settings.value("LensWD/LENS5", 0.0).toDouble();

    m_lensX[0] = settings.value("LensX/LENS0", 0.0).toDouble();
    m_lensX[1] = settings.value("LensX/LENS1", 0.0).toDouble();
    m_lensX[2] = settings.value("LensX/LENS2", 0.0).toDouble();
    m_lensX[3] = settings.value("LensX/LENS3", 0.0).toDouble();
    m_lensX[4] = settings.value("LensX/LENS4", 0.0).toDouble();
    m_lensX[5] = settings.value("LensX/LENS5", 0.0).toDouble();

    m_lensY[0] = settings.value("LensY/LENS0", 0.0).toDouble();
    m_lensY[1] = settings.value("LensY/LENS1", 0.0).toDouble();
    m_lensY[2] = settings.value("LensY/LENS2", 0.0).toDouble();
    m_lensY[3] = settings.value("LensY/LENS3", 0.0).toDouble();
    m_lensY[4] = settings.value("LensY/LENS4", 0.0).toDouble();
    m_lensY[5] = settings.value("LensY/LENS5", 0.0).toDouble();
}

double LensCompensation::xCompensate(int oldlens, int newlens)
{
    return m_lensX[newlens] - m_lensX[oldlens];
}

double LensCompensation::yCompensate(int oldlens, int newlens)
{
    return m_lensY[newlens] - m_lensY[oldlens];
}

double LensCompensation::workingDistanceCompensate(int oldlens, int newlens)
{
    return m_lensWD[newlens] - m_lensWD[oldlens];
}
